<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Amazon Form Encrypt</title>
    <script src="amazon_form_encrypt.js"></script>
    <script>
        key = [1888420705,2576816180, 2347232058, 874813317]
        
        var createHistogram = function (t) {
            for (var e = [], a = 0; a < 256; e[a++] = 0);
            for (var l = 0; l < t.length; l++)
                e[t[l]]++;
            return e;
        }

        var test = function() {
           canvas = document.createElement("canvas")
           var newCanvas;
           var vector = {}
           vector.r = 3
           vector.g = 1
           vector.b = 14
           vector.a = 7
           
           return (t = [], 
                    canvas.width = 150, 
                    canvas.height = 60, 
                    canvas.style.display = "inline", 
                    (a = canvas.getContext("2d"), a = fakeImageData(a, canvas.width, canvas.height, vector)).rect(0, 0, 10, 10), 
                    a.rect(2, 2, 6, 6), 
                    t.push(0 == a.isPointInPath(5, 5, "evenodd") ? "yes" : "no"), 
                    a.textBaseline = "alphabetic", 
                    a.fillStyle = "#f60", 
                    a.fillRect(125, 1, 62, 20), 
                    a.fillStyle = "#069", 
                    a.font = "8pt Arial", 
                    a.fillText("Cwm fjordbank glyphs vext quiz,", 2, 15), 
                    a.fillStyle = "rgba(102, 204, 0, 0.2)", 
                    a.font = "11pt Arial", 
                    a.fillText("Cwm fjordbank glyphs vext quiz,", 4, 45), 
                    a.globalCompositeOperation = "multiply", 
                    a.fillStyle = "rgb(255,0,255)",
                    a.beginPath(), a.arc(20, 20, 20, 0, 2 * Math.PI, 1), 
                    a.closePath(), a.fill(), 
                    a.fillStyle = "rgb(0,255,255)", 
                    a.beginPath(), 
                    a.arc(50, 20, 20, 0, 2 * Math.PI, 1), 
                    a.closePath(), a.fill(), 
                    a.fillStyle = "rgb(255,255,0)", 
                    a.beginPath(),
                    a.arc(35, 40, 20, 0, 2 * Math.PI, 1), 
                    a.closePath(), a.fill(), 
                    a.fillStyle = "rgb(255,0,255)", 
                    a.arc(20, 25, 10, 0, 2 * Math.PI, 1), 
                    a.arc(20, 25, 20, 0, 2 * Math.PI, 1), 
                    a.fill("evenodd"), 
                    (l = a.createLinearGradient(40, 50, 60, 78)).addColorStop(0, "blue"), 
                    l.addColorStop(0.5, "red"), 
                    l.addColorStop(1, "white"), 
                    a.fillStyle = l, 
                    a.beginPath(), 
                    a.arc(70, 50, 10, 0, 2 * Math.PI, 1), 
                    a.closePath(), 
                    a.fill(), 
                    a.font = "10pt dfgstg", 
                    a.strokeText(Math.tan(-1e+300).toString(), 4, 30), 
                    a.fillText(Math.cos(-1e+300).toString(), 4, 40), 
                    a.fillText(Math.sin(-1e+300).toString(),4, 50), 
                    a.beginPath(), a.moveTo(25, 0), 
                    a.quadraticCurveTo(1, 1, 1, 5), 
                    a.quadraticCurveTo(1, 76, 26, 10), 
                    a.quadraticCurveTo(26, 96, 6, 12), 
                    a.quadraticCurveTo(60, 96, 41, 10), 
                    a.quadraticCurveTo(121, 86, 101, 7), 
                    a.quadraticCurveTo(121, 1, 56, 1), 
                    a.stroke(), 
                    a.globalCompositeOperation = "difference", 
                    a.fillStyle = "rgb(255,0,255)", 
                    a.beginPath(), a.arc(80, 20, 20, 0, 2 * Math.PI, 1), 
                    a.closePath(), a.fill(), 
                    a.fillStyle = "rgb(0,255,255)", 
                    a.beginPath(), 
                    a.arc(110, 20, 20, 0, 2 * Math.PI, 1), 
                    a.closePath(), a.fill(), 
                    a.fillStyle = "rgb(255,255,0)",
                    a.beginPath(), 
                    a.arc(95, 40, 20, 0, 2 * Math.PI, 1), 
                    a.closePath(), 
                    a.fill(), 
                    a.fillStyle = "rgb(255,0,255)", 
                    t.push("canvas fp:" + canvas.toDataURL()), 
                    i = crc32(t.join("~")), 
                    r = null, 
                    // form && 
                    (o = document.querySelectorAll("input[type=email]")).length > 0 && 
                    (n = o[0],  c = (n.value || "Not Available").toUpperCase(),  a.fillStyle = "#808080", a.font = "8pt Arial",  a.fillText(c, 2, 30), r = crc32(canvas.toDataURL())), 
                        [2,{
                                canvas: {
                                    hash: i,
                                    emailHash: r,
                                    histogramBins: createHistogram(a.getImageData(0, 0, 150, 60).data)
                                }
                            }
                        ]
            )
        }

        // console.log(test())
</script>
</head>
<body>
        <input type="file" id="input">
<input type="input" value="" id="content" style="width:1000px;height:500px">
<button onclick="decode()" value="decode" name="decode" style="height:500px">Decode</button>
<button onclick="encode()" value="encode" name="encode" style="height:500px">Encode</button>
<div id="result"></div>
</body>
</html>
<script>

	var decode = function(){
		key = [1888420705,2576816180, 2347232058, 874813317]
        content = document.getElementById("content").value;
        console.log(xxtea_decrypt(Base64.decode64(content), key))
    }

    var encode = function() {
        key = [1888420705,2576816180, 2347232058, 874813317]
        content = document.getElementById("content").value;
        // console.log(Base64.encode64(xxtea_encrypt(content, key)))
        console.log(Base64.encode64(xxtea_encrypt(encodeObject(content), key)))
    }
</script>